home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / Buildable, limited OOFILE / samples / ooftst16.inc < prev    next >
Text File  |  1996-03-31  |  2KB  |  83 lines

  1. // included in ooftst16
  2.  
  3. DECLARE_REF(dbPatients)
  4. DECLARE_SET(dbVisits)
  5.  
  6. DECLARE_CLASS(dbPatients)
  7.     dbChar        LastName, Othernames;
  8.     dbVisitsSet    Visits;
  9.     dbLong        Salary;
  10.  
  11.     dbPatients() :
  12.                 LastName(40, "Last Name", kIndexed),
  13.                 Othernames(80, "Other names", kIndexed),
  14.                 Salary("Salary", kIndexed)
  15.     {};
  16.     
  17. // my own data entry procedures
  18.     void Add(const char *lname, const char *oname, const long salary);
  19.     void AddVisit(const char* visitDate, const char* why);
  20.     void AddTestData();
  21.     
  22. };
  23.  
  24.  
  25. DECLARE_CLASS(dbVisits)
  26.     dbPatientsRef    Patient;
  27.     dbDate        VisitDate;
  28.     dbChar        Why;
  29.     dbVisits() : 
  30.                 VisitDate("VisitDate", kIndexed),
  31.                 Why(200, "Reason for Visit", kIndexCompress)
  32.     {};
  33. };
  34.  
  35.  
  36. void dbPatients::Add(const char *lname, const char *oname, const long salary)
  37. {
  38.     newRecord();
  39.     LastName = lname;
  40.     Othernames = oname;
  41.     Salary = salary;
  42.     saveRecord();
  43. }
  44.  
  45.  
  46. void dbPatients::AddVisit(const char* visitDate, const char* why)
  47. {
  48.     Visits->newRecord();
  49.     Visits->VisitDate = visitDate;
  50.     Visits->Why = why;
  51. }
  52.  
  53.  
  54. void dbPatients::AddTestData()
  55. {
  56. // yes, if using SmartHeap debugging the following can take long enough to make folks wonder
  57. // there are a *lot* of places where OOFILE calls SmartHeap to check memory
  58.         cout << "Generating new test records..." << flush;
  59.         Add("Smith", "John", 20000);
  60.             AddVisit("1/10/1994", "Sore Knee");
  61.             AddVisit("14/10/1994", "Measles");
  62.         saveRecord();
  63.         
  64.         Add("DENT", "Trissa", 99999);
  65.             AddVisit("23-11-1994", "Flu");
  66.         saveRecord();
  67.  
  68.         Add("Dent", "Andy", 50000);
  69.             AddVisit("4.10.1994", "Flu");
  70.         saveRecord();
  71.  
  72.         Add("Taylor", "Ken", 75000);
  73.         cout << endl << endl;
  74. }
  75.  
  76.  
  77. // global variables that define the database using the above classes
  78.  
  79.     dbConnect_ctree    theDB;
  80.     dbPatients     Patients;
  81.     dbVisits    Visits;
  82.     dbRelationship PatientVisits(Patients.Visits, Visits.Patient);
  83.